# coding:utf-8

import os
import set_env_path     # 请勿删除


from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine, text
from sqlalchemy.orm import sessionmaker

Base = declarative_base()
engine = create_engine(
    os.getenv('DATABASE_URL')
    or 'mysql+pymysql://root:@127.0.0.1/wph_www_prod?charset=utf8'
)
Session = sessionmaker(bind=engine)
session = Session()


def sync_water_factor():
    """
    add by zhouhl 2018-04-25
    """
    # 一线城市
    session.execute("""
        update area set water_factor=1.6 where level=1 and type=2;
    """)
    # 常规城市
    session.execute("""
        update area set water_factor=1.4 where level=2 and type=2;
    """)
    # 偏远地区
    session.execute("""
        update area set water_factor=1.0 where level=3 and type=2;
    """)
    session.commit()


if __name__ == '__main__':
    sync_water_factor()
